feature: Detect coursier if it's available locally - #524
Conversation
This should help with cases, where downloading coursier automatically is problematic. Next step would be to also download it automatically when needed.
ckipp01
left a comment
There was a problem hiding this comment.
So I see there is a fetchMetals.test.ts, but that only is looking at versions. There aren't really any tests that ensure this works. Do you think it'd make sense to try and add some?
I don't have any strong feelings about this btw, since coc-metals is deprecated, the VS Code extension is really the only thing using this now. If it's easier this can all be inlined if need be as well.
| } else return [p]; | ||
| }) | ||
| .find( | ||
| (p) => p.endsWith(path.sep + "cs") || p.endsWith(path.sep + "coursier") |
There was a problem hiding this comment.
It's probably not a huge deal, but I had a lot of problems with this in nvim-metals when trying to find cs on windows. I think this will just pass over and default to coursier which is fine, but if you did also want to check for windows and a cs.bat I do that here. Again, I don't think we need to, but looking for cs on windows won't work afaik.
| "-p", | ||
| ]; | ||
|
|
||
| let possibleCoursier = process.env["PATH"] |
| if (possibleCoursier) { | ||
| let coursier: string = possibleCoursier; | ||
| console.debug(`Using coursier located at ${coursier}`); | ||
| output.appendLine(`Using coursier located at ${coursier}`); | ||
| spawn(coursier, ["version"]) | ||
| .then((_out) => spawn(coursier, coursierArgs)) | ||
| .catch((err: Error) => { | ||
| output.appendLine(err.message); | ||
| console.debug(err); | ||
| return spawnDefault(); | ||
| }); | ||
| } | ||
| return spawnDefault(); |
There was a problem hiding this comment.
right now this won't work at all because if branch doesn't have return statement so spawn(coursier, ["version"]) will be discarded and spawnDefault promise will be returned.
This should help with cases, where downloading coursier automatically is problematic.
Next step would be to also download it automatically when needed.